<template>
  <div>
    <van-nav-bar title="我的任务" left-text="" left-arrow @click-left="router.go(-1)" />
    <div class="shang">
      <div class="taskimg">
        签到条
      </div>
      <div>
        <van-steps :active="active">
          <van-step>+1</van-step>
          <van-step>+2</van-step>
          <van-step>+3</van-step>
          <van-step>+4</van-step>
          <van-step>+5</van-step>
          <van-step>+10</van-step>
          <van-step>+10</van-step>
        </van-steps>
        <div style="display: flex">
          <div
            v-for="(item, index) in ['1', '2', '3', '4', '5', '6','N']"
            style="width: 59rem; text-align: center"
          >
            {{ item }}天
          </div>
        </div>
      </div>
    </div>
    <div class="zhong">
      <div class="taskimg">每日任务</div>
      <div>
        <div class="a1">
          <div>签到</div>
          <div><el-button type="primary" :disabled="flag">{{ flagtitle }}</el-button></div>
        </div>
        <div class="a1">
          <div>首发病友圈<br />+10H币</div>
          <div><el-button type="primary" @click="gotoBing">去完成</el-button></div>
        </div>
        <div class="a1">
          <div>病友圈首评<br />+10H币</div>
          <div><el-button type="primary">领H币</el-button></div>
        </div>
      </div>
    </div>
    <div class="xia">
      <div class="taskimg">一次性任务</div>
      <div class="a1">
        <div>完善我的信息<br />+30H币</div>
        <div><el-button type="primary" @click="gotoMessage">去完成</el-button></div>
      </div>
      <div class="a1">
        <div>参与健康测评<br />+10H币</div>
        <div><el-button type="primary">去完成</el-button></div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { findUserSign, whetherSignToday } from '@/api/search';
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const userId = ref(parseInt(localStorage.getItem('userId') as string))
const sessionId = ref(JSON.parse(localStorage.getItem('sessionId') as string))
const flag = ref(false)
const flagtitle=ref("签到")
const active=ref(-1)
const router=useRouter();
const whetherSignToday1=async()=>{
  const res=await whetherSignToday(userId.value,sessionId.value)
  console.log("查询是否签到",res);
  if(res.data.status=="0000"){
    flag.value=true;
    flagtitle.value="已签到"
  }
  
}
whetherSignToday1()

const findUserSign1=async()=>{
  const res =await findUserSign(userId.value,sessionId.value)
  console.log("查询用户连续签到天数",res);
  active.value=res.data.result-1
}
findUserSign1();

const gotoBing=()=>{
  router.push("/publishSickCircle")
}
const gotoMessage=()=>{
  router.push("/gotoMessage")
}
</script>
<style>
@import './task.scss';
</style>